package com.miplus.ccrm.core.service.iou;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.miplus.ccrm.core.controller.vo.iou.IBillResVo;
import com.miplus.ccrm.core.controller.vo.iou.IPayPlanReqVo;
import com.miplus.ccrm.core.controller.vo.iou.IPayPlanResVo;
import com.miplus.ccrm.core.pojo.IouBillPayplan;
import com.miplus.ccrm.core.mapper.IouBillPayplanMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author pc
* @description 针对表【IOU_BILL_PAYPLAN(借据还款计划表)】的数据库操作Service实现
* @createDate 2024-10-26 12:44:37
*/
@Service
public class IouBillPayplanServiceImpl extends MPJBaseServiceImpl<IouBillPayplanMapper, IouBillPayplan>
    implements IouBillPayplanService{

    @Resource
    private IouCommand iouCommand;

    @Override
    public IPage<IPayPlanResVo> payplanList(IPayPlanReqVo paras)
    {
        return selectJoinListPage(new Page<>(paras.getPageNum(), paras.getPageSize()),
                IPayPlanResVo.class,
                new MPJLambdaWrapper<IouBillPayplan>()
                        .selectAs("fun_getnames('COLLECT.AMORT.STATUS',t.status)", IBillResVo::getStatusdsc)
                        .selectAll(IouBillPayplan.class)
                        .eq(IouBillPayplan::getBillid,paras.getBillno())
                        .orderByAsc(IouBillPayplan::getCurrentNum)
        );
    }

    @Override
    public List<IPayPlanResVo> quyPayplan(String billno)
    {
        return iouCommand.cmdBillPayplan(billno);
    }
}




